home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple Developer Connection Student Program
/
ADC Tools Sampler CD Disk 3 1999.iso
/
Cool Demos, SDKs, & Tools
/
Demos⁄Tools⁄Offers
/
Eiffel for CW beta 3
/
EiffelS2
/
LIBRARY
/
MOTEL
/
Controls.c
next >
Wrap
Text File
|
1999-05-18
|
4KB
|
163 lines
/*------------------------------------------------------------------*/
/* Eiffel/S II MacOS Runtime */
/*------------------------------------------------------------------*/
/* Author : Ian Joyner */
/* Release : 1.0 */
/* Date : Dec. 1997 */
/* Copyright : Ian Joyner */
/*------------------------------------------------------------------*/
/********************************************************************/
/* */
/* CONTROLs */
/* */
/********************************************************************/
#include <Controls.h>
#include <Eiffel2.h>
#include "MOTEL.h"
#include <cecil.h>
INTEGER platform_control_size ()
{
ControlRecord p;
return (sizeof (p));
}
ControlHandle platform_control_new (WindowPtr w, INTEGER left, INTEGER top, INTEGER right, INTEGER bottom,
ConstStr255Param title, Boolean visible,
INTEGER value, INTEGER min, INTEGER max,
INTEGER proc_id, INTEGER refCon)
{
Rect bounds_rect;
WindowPtr wp;
Str255 scratch;
SetRect (&bounds_rect, left, top, right, bottom);
strcpy (scratch, title);
c2pstr ((char *)scratch); /* This might not be right if string is loaded from a resource */
return NewControl (w, &bounds_rect, scratch, visible, value, min, max, proc_id, refCon);
}
ControlHandle platform_control_get (INTEGER control_id, WindowPtr the_window, INTEGER eiffel_object)
{
ControlHandle new_control = GetNewControl (control_id, the_window);
SetControlReference (new_control, eiffel_object);
return new_control;
}
POINTER platform_control_get_title (ControlHandle c)
{
GetControlTitle (c, &scratch_string);
return &scratch_string;
}
void platform_control_set_title (ControlHandle c, ConstStr255Param title)
{
Str255 scratch;
strcpy (scratch, title);
c2pstr ((char *)scratch); /* This might not be right if string is loaded from a resource */
SetControlTitle (c, scratch);
}
void platform_control_highlight (ControlHandle c, INTEGER state)
{
HiliteControl (c, state);
}
INTEGER platform_control_test (ControlHandle c, INTEGER x, INTEGER y)
{
Point p;
SetPt (&p, x, y);
return TestControl (c, p);
}
void platform_control_move (ControlHandle c, INTEGER h, INTEGER v)
{
MoveControl (c, h, v);
}
void platform_control_drag (ControlHandle c, INTEGER x, INTEGER y, INTEGER ll, INTEGER lt, INTEGER lr, INTEGER lb,
INTEGER sl, INTEGER st, INTEGER sr, INTEGER sb, INTEGER axis)
{
Point p;
Rect limit_rect, slop_rect;
SetPt (&p, x, y);
SetRect (&limit_rect, ll, lt, lr, lb);
SetRect (&slop_rect, sl, st, sr, sb);
DragControl (c, p, &limit_rect, &slop_rect, axis);
}
void platform_control_resize (ControlHandle c, INTEGER w, INTEGER h)
{
SizeControl (c, w, h);
}
void platform_control_set_value (ControlHandle c, INTEGER new_value)
{
SetControlValue (c, new_value);
}
INTEGER platform_control_get_value (ControlHandle c)
{
return GetControlValue (c);
}
void platform_control_set_minimum (ControlHandle c, INTEGER new_minimum)
{
SetControlMinimum (c, new_minimum);
}
INTEGER platform_control_get_minimum (ControlHandle c)
{
return GetControlMinimum (c);
}
void platform_control_set_maximum (ControlHandle c, INTEGER new_maximum)
{
SetControlMaximum (c, new_maximum);
}
INTEGER platform_control_get_maximum (ControlHandle c)
{
return GetControlMaximum (c);
}
EIF_PROC scroll_handler;
static pascal void control_handler (ControlRef c, short part)
{
if (!scroll_handler)
scroll_handler = eif_proc ("scroll_handler", eif_type_id ("SCROLL_BAR"));
(eif_proc_call (scroll_handler))(eif_access((*c)->contrlRfCon), part);
}
#if GENERATINGCFM
static RoutineDescriptor chRD = BUILD_ROUTINE_DESCRIPTOR(uppControlActionProcInfo, control_handler);
static ControlActionUPP pch = &chRD;
#else
static ControlActionUPP pch = control_handler;
#endif
INTEGER platform_control_track (ControlHandle c, INTEGER x, INTEGER y, POINTER routine)
{
Point p;
SetPt (&p, x, y);
if (routine == NULL)
{
return TrackControl (c, p, NULL);
}
else
{
return TrackControl (c, p, pch);
}
}